package dc.exam;

import java.util.Map;
import java.util.TreeMap;

import bbb.sss.Utils;

public class Main1 {

	public static void test1() {
		int count = 1600;
		int i = 1;
		int[] a = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		Map<Integer, Integer> lengthCount = new TreeMap<Integer, Integer>();
		System.out.println(a.length);

		int avgStep = 0;
		while (i <= count) {
			int code = Utils.randomNumber(16);
			int ss = i - a[code - 1];
			avgStep += ss;
			a[code - 1] = i;
//			System.out.println(i + " : " + code + " - " + ss);

			Integer cur = lengthCount.get(ss);
			if (cur == null) {
				lengthCount.put(ss, 1);
			} else {
				lengthCount.put(ss, cur + 1);
			}

			i++;
		}

		System.out.println(avgStep * 1.0 / count);

		double ac = 0.0;
		for (Integer key : lengthCount.keySet()) {
			ac += lengthCount.get(key) * 1.0 / count;
			System.out.println(key + " " + lengthCount.get(key) + " "
					+ (lengthCount.get(key) * 1.0 / count) + " "+ac);
		}

	}

	public static void main(String[] args) {
		test1();
	}

}
